<?php 
set_time_limit(0);
ini_set("memory_limit", "12M");
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include_once '../value/value_kr.php';
include_once 'checklogin.php';

$currentdate = date("Y");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	ScrollTable();
	
});
function MyResize(){
	ScrollTable();
}

function ScrollTable(){
	wid = $("table#tablebody").parent().css('width');
	wid = wid.slice(0,-2)-18;
	$("table#tablebody").css("width", wid);
	$("table#tableheader").css("width", wid);
	$('table#tablebody').parent().scrollTop(0);
	OnTRCSS();
}

function OnTRCSS(){
	$("table.tbchung tr:even").each(function(){
		$(this).css("background-color","#eff3fa");
	});
}

</script>
<script type="text/javascript">
function OnSearch(){
	var winHf = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	temp = $("#divscroll").position();
	var winH = parseInt(winHf - temp.top - 15);
	
	var s_month = $("#s_month").val();
	var s_year = $("#s_year").val();
	$('body').css('cursor','wait');
	$.ajax({url:"ajax_searchs.php", data:{ s_month:s_month , s_year:s_year,winH:winH } , success:function(result){
		var expr = new RegExp('>[ \t\r\n\v\f]*<', 'g');
		var response_html_fixed = result.replace(expr, '><');
		$('body').css('cursor','auto');
		if(response_html_fixed.indexOf('<tr')>-1){
			$("#mycontent").empty();
			$("#mycontent").html(response_html_fixed);
			ScrollTable();
		}else{
			$("#tablebody tr").remove();
			$("#tablefooter").remove();
		}
	}});
}

function OnSearchSort(ele){
	flag = $(ele).attr('values');
	if(flag=='10'){
		$(ele).attr('values','11');
	}else if(flag=='11'){
		$(ele).attr('values','10');
	}
	else if(flag=='20'){
		$(ele).attr('values','21');
	}else if(flag=='21'){
		$(ele).attr('values','20');
	}
	else if(flag=='30'){
		$(ele).attr('values','31');
	}else if(flag=='31'){
		$(ele).attr('values','30');
	}
	else if(flag=='40'){
		$(ele).attr('values','41');
	}else if(flag=='41'){
		$(ele).attr('values','40');
	}
	else if(flag=='50'){
		$(ele).attr('values','51');
	}else if(flag=='51'){
		$(ele).attr('values','50');
	}
	else if(flag=='60'){
		$(ele).attr('values','61');
	}else if(flag=='61'){
		$(ele).attr('values','60');
	}
	else if(flag=='70'){
		$(ele).attr('values','71');
	}else if(flag=='71'){
		$(ele).attr('values','70');
	}
	
	$.ajax({url:"ajax_searchssort.php", data:{ flag:flag} , success:function(result){
		var expr = new RegExp('>[ \t\r\n\v\f]*<', 'g');
		var response_html_fixed = result.replace(expr, '><');
		$("#tablebody tr").remove();
		$("#tablebody tbody").append(response_html_fixed);
		ScrollTable();
	}});
}

function OnPagging(pageNum,rows_per_page,number_of_page){
	$.ajax({url:"ajax_searchspagging.php", data:{ pageNum:pageNum,rows_per_page:rows_per_page,number_of_page:number_of_page } , success:function(result){
		$("#tablebody tr").remove();
		$("#tablebody tbody").append(result);
		ScrollTable();
		
	}});
	$.ajax({url:"ajax_searchspaggingfooter.php", data:{ pageNum:pageNum,rows_per_page:rows_per_page,number_of_page:number_of_page } , success:function(result){
		$("#tablefooter tr").remove();
		$("#tablefooter tbody").append(result);

		$("table#tableheader th[name='th1']").attr('pages',pageNum);
		$("table#tableheader th[name='th2']").attr('pages',pageNum);
		$("table#tableheader th[name='th3']").attr('pages',pageNum);
		$("table#tableheader th[name='th4']").attr('pages',pageNum);
		$("table#tableheader th[name='th5']").attr('pages',pageNum);
		$("table#tableheader th[name='th6']").attr('pages',pageNum);
		$("table#tableheader th[name='th7']").attr('pages',pageNum);
		
	}});
	
	
}

function loadpos(){
	var winHf = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	temp = $("#divscroll").position();
	$("#divscroll").css("height", parseInt(winHf - temp.top - 15));
}
</script>

</head>
<?php include 'show_function_popup_carcrime.php';?>
<body onresize="MyResize()"  onload="loadpos();load_popup_carCrime();">
<p id="maylya" ><input type="hidden"  id="mayly" name="mayly" /></p>
<?php include '../connection/connection_menu.php';
$monitor = $_REQUEST['monitor'];
$monitorname=$_REQUEST['monitorname'];
if (isset($_SESSION['monitor_menu'])) {
	$monitor = $_SESSION['monitor_menu'];
}

?>  
    <?php include 'menu.php';?>
    <div id="submenu">
    	<ul class="asubmenu">
    		<li><a href="searchcarnums.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>"><?=$l_recognitionrate?></a></li>
        	<li><a href="carnums.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>"><?=$l_s_canums?></a></li>
            <li><a href="trace.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_s_trace?></a></li>
            <li><a href="cameras.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_camera?></a></li>
            <li><a href="searchs.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>"  class="asubmenuselect"><?=$l_s_searchs?></a></li>
            <li><a href="alarms.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_s_alarms?></a></li>
            <li><a href="users.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_s_users?></a></li>
        </ul>
        <div class="clear"></div>
    </div>
     <?php mysql_close($connection_menu);?>
    <div class="main">
    	<table style="width:100%; padding:0; ">
    		<tr>
    			<td width="55">
    				<select style="width: 50px;height: 22px" id="s_month">
    					<option value="1">1</option>
    					<option value="2">2</option>
    					<option value="3">3</option>
    					<option value="4">4</option>
    					<option value="5">5</option>
    					<option value="6">6</option>
    					<option value="7">7</option>
    					<option value="8">8</option>
    					<option value="9">9</option>
    					<option value="10">10</option>
    					<option value="11">11</option>
    					<option value="12">12</option>
    				</select>
    			</td>
    			<td width="50" style="color:#ffffff"><?=$l_month?></td>
    			<td width="85">
    				<select style="width: 80px;height: 22px" id="s_year">
    					<option value="<?=$currentdate?>"><?=$currentdate?></option>
    					<?php for($k=1;$k<10;$k++){
    					?>
    					<option value="<?=$currentdate-$k?>"><?=$currentdate-$k?></option>
    					<?php }?>
    				</select>
    			</td>
    			<td  width="70" style="color:#ffffff"><?=$l_year?></td>
    			<td><input type="button" value="<?=$l_search?>" class="inbtn" style="width: 100px; height: 22px" onclick="OnSearch()" /></td>
    		</tr>
    	</table>
        <div style="width: 100%;height: 5px"></div>
        
        <div class="divtheader">
	    	<table  cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" style="border:none" id="tableheader">
	               <tr>
		                   <th width="14%" name="th1" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)"  values="10"><?=$l_s_date?></th>
		                   <th width="14%" name="th2" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)"  values="20"><?=$l_s_usersid?></th> 
		                   <th width="14%" name="th3" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)"  values="30"><?=$_s_datestart?></th>
		                   <th width="14%" name="th4" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)"  values="40"><?=$_s_dateend?></th> 
		                   <th width="14%" name="th5" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)"  values="50"><?=$l_s_cartype?></th> 
		                   <th width="14%" name="th6" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)"  values="60"><?=$l_carnum?></th> 
		                   <th class="last" name="th7" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)" values="70"><?=$l_s_way?></th> 
		                   
	               </tr>
	        </table>
    	</div>
        
        <div id="mycontent">
	        <div id="divscroll" style="overflow:scroll;overflow-x: hidden; width:100%; height:520px; background-color: #ffffff">
	               <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" style="margin-top:0" id="tablebody">
						 <tbody>
						 </tbody>       
	               </table>
	       </div>
        </div>
        
       <!--div style="width:100%; padding:10 0">
       		<label>모두 보기 &nbsp&nbsp</label>
       		<label style="width:1.5px; height: 30px;color: #ffffff; background-color: #ffffff">|</label>
       		<label>&nbsp adfasdfadf</label>
       </div>
       <div style="width:100%; padding:10 0; background-color: #ffffff">
       
       </div-->
              
    </div>
    <?php include 'show_content_popup_carcrime.php';?>
</body>     
</html>